class GoodBean {
   int code;
   String msg;
   GoodDataBean data;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodBean(this);
   GoodBean(Map<String,dynamic> json){
       jsonToBeanGoodBean(json,this);
   }
}

class GoodDataBean {
   String goodsId;
   String shopId;
   String name;
   String codeNum;
   List<String> pic;
   String description;
   String cid;
   List<String> cidPath;
   String cidName;
   String marketPrice;
   String discountPrice;
   String price;
   List<GoodDataPropFormatBean> propFormat;
   List<GoodDataSpecBean> spec;
   List<GoodDataSpecPicsBean> specPics;
   List<GoodDataPropIdsBean> propIds;
   int status;
   List<dynamic> materials;
   List<GoodDataSkuThisBean> thisSku=[];
   List<GoodDataSkuBean> sku;
   String created;
   int isCollected;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataBean(this);
   GoodDataBean(Map<String,dynamic> json){
       jsonToBeanGoodDataBean(json,this);
   }
}
class GoodDataPropFormatBean {
   String nameId;
   String valueId;
   String name;
   String value;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataPropFormatBean(this);
   GoodDataPropFormatBean(Map<String,dynamic> json){
       jsonToBeanGoodDataPropFormatBean(json,this);
   }
}
class GoodDataSpecBean {
   String name;
   String propNameId;
   List<GoodDataSpecListBean> list;
   String groupName;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataSpecBean(this);
   GoodDataSpecBean(Map<String,dynamic> json){
       jsonToBeanGoodDataSpecBean(json,this);
   }
}
class GoodDataSpecListBean {
   String name;
   String pic;
   String propId;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataSpecListBean(this);
   GoodDataSpecListBean(Map<String,dynamic> json){
       jsonToBeanGoodDataSpecListBean(json,this);
   }
}
class GoodDataSpecPicsBean {
   String propId;
   String pic;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataSpecPicsBean(this);
   GoodDataSpecPicsBean(Map<String,dynamic> json){
       jsonToBeanGoodDataSpecPicsBean(json,this);
   }
}
class GoodDataPropIdsBean {
   String propId;
   String name;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataPropIdsBean(this);
   GoodDataPropIdsBean(Map<String,dynamic> json){
       jsonToBeanGoodDataPropIdsBean(json,this);
   }
}

class GoodDataSkuThisBean{
   String name;
   String img;
   int num=0;
   List<GoodDataSkuBean> child=[];
}
class GoodDataSkuBean {
   String skuId;
   String goodsId;
   String outSkuId;
   String skuCode;
   List<String> propKey;
   List<String> propVal;
   String get name=>propVal.last;
   String propImg;
   String price;
   String stockNum;
   int num=0;
   String created;
   String modified;
   List<String> propId;
   List<String> propKeyId;

   Map<String,dynamic> toJson()=>jsonFromBeanGoodDataSkuBean(this);
   GoodDataSkuBean(Map<String,dynamic> json){
       jsonToBeanGoodDataSkuBean(json,this);
   }
}

//-------------------------------解析方法---------------------------------

void jsonToBeanGoodBean(Map<String,dynamic> json,GoodBean bean){
   if(json==null) return;
   bean.code=int.parse(json["code"]?.toString()??"0");
   bean.msg=json["msg"]?.toString()??"";
   bean.data=GoodDataBean(json["data"]);
}
void jsonToBeanGoodDataBean(Map<String,dynamic> json,GoodDataBean bean){
   if(json==null) return;
   bean.goodsId=json["goods_id"]?.toString()??"";
   bean.shopId=json["shop_id"]?.toString()??"";
   bean.name=json["name"]?.toString()??"";
   bean.codeNum=json["code_num"]?.toString()??"";
   bean.pic=[];
   for(var item in json["pic"]){
      bean.pic.add(item?.toString()??"");
   }
   bean.description=json["description"]?.toString()??"";
   bean.cid=json["cid"]?.toString()??"";
   bean.cidPath=[];
   for(var item in json["cid_path"]){
      bean.cidPath.add(item?.toString()??"");
   }
   bean.cidName=json["cid_name"]?.toString()??"";
   bean.marketPrice=json["market_price"]?.toString()??"";
   bean.discountPrice=json["discount_price"]?.toString()??"";
   bean.price=json["price"]?.toString()??"";
   bean.propFormat=[];
   for(var item in json["prop_format"]){
      bean.propFormat.add(GoodDataPropFormatBean(item));
   }
   bean.spec=[];
   for(var item in json["spec"]){
      bean.spec.add(GoodDataSpecBean(item));
   }
   bean.specPics=[];
   for(var item in json["spec_pics"]){
      bean.specPics.add(GoodDataSpecPicsBean(item));
   }
   bean.propIds=[];
   for(var item in json["prop_ids"]){
      bean.propIds.add(GoodDataPropIdsBean(item));
   }
   bean.status=int.parse(json["status"]?.toString()??"0");
   bean.materials=[];
   for(var item in json["materials"]){
      bean.materials.add(item?.toString()??"");
   }
   bean.sku=[];
   for(var item in json["sku"]){
      bean.sku.add(GoodDataSkuBean(item));
   }
   bean.created=json["created"]?.toString()??"";
   bean.isCollected=int.parse(json["is_collected"]?.toString()??"0");
}
void jsonToBeanGoodDataPropFormatBean(Map<String,dynamic> json,GoodDataPropFormatBean bean){
   if(json==null) return;
   bean.nameId=json["name_id"]?.toString()??"";
   bean.valueId=json["value_id"]?.toString()??"";
   bean.name=json["name"]?.toString()??"";
   bean.value=json["value"]?.toString()??"";
}
void jsonToBeanGoodDataSpecBean(Map<String,dynamic> json,GoodDataSpecBean bean){
   if(json==null) return;
   bean.name=json["name"]?.toString()??"";
   bean.propNameId=json["prop_name_id"]?.toString()??"";
   bean.list=[];
   for(var item in json["list"]){
      bean.list.add(GoodDataSpecListBean(item));
   }
   bean.groupName=json["group_name"]?.toString()??"";
}
void jsonToBeanGoodDataSpecListBean(Map<String,dynamic> json,GoodDataSpecListBean bean){
   if(json==null) return;
   bean.name=json["name"]?.toString()??"";
   bean.pic=json["pic"]?.toString()??"";
   bean.propId=json["prop_id"]?.toString()??"";
}
void jsonToBeanGoodDataSpecPicsBean(Map<String,dynamic> json,GoodDataSpecPicsBean bean){
   if(json==null) return;
   bean.propId=json["prop_id"]?.toString()??"";
   bean.pic=json["pic"]?.toString()??"";
}
void jsonToBeanGoodDataPropIdsBean(Map<String,dynamic> json,GoodDataPropIdsBean bean){
   if(json==null) return;
   bean.propId=json["prop_id"]?.toString()??"";
   bean.name=json["name"]?.toString()??"";
}
void jsonToBeanGoodDataSkuBean(Map<String,dynamic> json,GoodDataSkuBean bean){
   if(json==null) return;
   bean.skuId=json["sku_id"]?.toString()??"";
   bean.goodsId=json["goods_id"]?.toString()??"";
   bean.outSkuId=json["out_sku_id"]?.toString()??"";
   bean.skuCode=json["sku_code"]?.toString()??"";
   bean.propKey=[];
   for(var item in json["prop_key"]){
      bean.propKey.add(item?.toString()??"");
   }
   bean.propVal=[];
   for(var item in json["prop_val"]){
      bean.propVal.add(item?.toString()??"");
   }
   bean.propImg=json["prop_img"]?.toString()??"";
   bean.price=json["price"]?.toString()??"";
   bean.stockNum=json["stock_num"]?.toString()??"";
   bean.created=json["created"]?.toString()??"";
   bean.modified=json["modified"]?.toString()??"";
   bean.propId=[];
   for(var item in json["prop_id"]){
      bean.propId.add(item?.toString()??"");
   }
   bean.propKeyId=[];
   for(var item in json["prop_key_id"]){
      bean.propKeyId.add(item?.toString()??"");
   }
}

Map<String,dynamic> jsonFromBeanGoodBean(GoodBean bean)=>{
   "code":bean.code,
   "msg":bean.msg,
   "data":bean.data.toJson()
};

Map<String,dynamic> jsonFromBeanGoodDataBean(GoodDataBean bean)=>{
   "goods_id":bean.goodsId,
   "shop_id":bean.shopId,
   "name":bean.name,
   "code_num":bean.codeNum,
   "pic":bean.pic,
   "description":bean.description,
   "cid":bean.cid,
   "cid_path":bean.cidPath,
   "cid_name":bean.cidName,
   "market_price":bean.marketPrice,
   "discount_price":bean.discountPrice,
   "price":bean.price,
   "prop_format":bean.propFormat.map((e)=>e.toJson()).toList(),
   "spec":bean.spec.map((e)=>e.toJson()).toList(),
   "spec_pics":bean.specPics.map((e)=>e.toJson()).toList(),
   "prop_ids":bean.propIds.map((e)=>e.toJson()).toList(),
   "status":bean.status,
   "materials":bean.materials,
   "sku":bean.sku.map((e)=>e.toJson()).toList(),
   "created":bean.created,
   "is_collected":bean.isCollected
};

Map<String,dynamic> jsonFromBeanGoodDataPropFormatBean(GoodDataPropFormatBean bean)=>{
   "name_id":bean.nameId,
   "value_id":bean.valueId,
   "name":bean.name,
   "value":bean.value
};

Map<String,dynamic> jsonFromBeanGoodDataSpecBean(GoodDataSpecBean bean)=>{
   "name":bean.name,
   "prop_name_id":bean.propNameId,
   "list":bean.list.map((e)=>e.toJson()).toList(),
   "group_name":bean.groupName
};

Map<String,dynamic> jsonFromBeanGoodDataSpecListBean(GoodDataSpecListBean bean)=>{
   "name":bean.name,
   "pic":bean.pic,
   "prop_id":bean.propId
};

Map<String,dynamic> jsonFromBeanGoodDataSpecPicsBean(GoodDataSpecPicsBean bean)=>{
   "prop_id":bean.propId,
   "pic":bean.pic
};

Map<String,dynamic> jsonFromBeanGoodDataPropIdsBean(GoodDataPropIdsBean bean)=>{
   "prop_id":bean.propId,
   "name":bean.name
};

Map<String,dynamic> jsonFromBeanGoodDataSkuBean(GoodDataSkuBean bean)=>{
   "sku_id":bean.skuId,
   "goods_id":bean.goodsId,
   "out_sku_id":bean.outSkuId,
   "sku_code":bean.skuCode,
   "prop_key":bean.propKey,
   "prop_val":bean.propVal,
   "prop_img":bean.propImg,
   "price":bean.price,
   "stock_num":bean.stockNum,
   "created":bean.created,
   "modified":bean.modified,
   "prop_id":bean.propId,
   "prop_key_id":bean.propKeyId
};


